local thbattle__quanzouhua_jiandun = fk.CreateSkill {

  name = "thbattle__quanzouhua_jiandun",

  tags = {  },

}



thbattle__quanzouhua_jiandun:addEffect(fk.TargetConfirmed, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    if target ~= player and player:hasSkill(thbattle__quanzouhua_jiandun.name) and player:distanceTo(target) <= 1 and data.card and data.from ~= target and data.from ~= player and
        (data.card.trueName == "slash" or (data.card.type == Card.TypeTrick and data.card.multiple_targets ~= true)) and data.from.phase == Player.Play then
      local use_events = player.room.logic:getEventsOfScope(GameEvent.UseCard, 2, function(e)
        local use = e.data
        return use.from == data.from
      end, Player.HistoryPhase)
      return #use_events == 1
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, thbattle__quanzouhua_jiandun.name, nil,
      "#thbattle__quanzouhua_jiandun:" .. target.id .. ":" .. data.from.id .. ":" .. data.card:toLogString())
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    data:cancelTarget(target)
    local use_player = data.from
    use_player:addToPile("$thbattle_jiaoxie", data.card, false, thbattle__quanzouhua_jiandun.name)
    return true
  end,
})
thbattle__quanzouhua_jiandun:addEffect(fk.EventPhaseEnd, {
  can_refresh = function(self, event, target, player, data)
    return target == player and #player:getPile("$thbattle_jiaoxie") > 0 and player.phase == Player.Discard
  end,
  on_refresh = function(self, event, target, player, data)
    local cards = player:getPile("$thbattle_jiaoxie")
    player.room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonJustMove, thbattle__quanzouhua_jiandun.name, nil, false, player)
  end,
})

return thbattle__quanzouhua_jiandun